package cn.hd.controller;

import cn.hd.entity.ProductLevel;
import cn.hd.entity.Productdetail;
import cn.hd.entity.Result;
import cn.hd.service.ProductLevelService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin
public class ProductLevelController {
    @Autowired
    private ProductLevelService service;
    @RequestMapping("/selectProductLevelOne")
    public Object ProductLevelOne(){
        List<ProductLevel> pro = service.selectProductLevelOne();
        if (pro.size()!=0){
            return new Result("200","查询成功！",pro);
        }
        return new Result("400","查询失败！",null);
         }

    @RequestMapping("/selectProductLevelTwo")
    public Object ProductLevelTwo(){
        List<ProductLevel> pro = service.selectProductLevelTwo();
        if (pro.size()!=0){
            return new Result("200","查询成功！",pro);
        }
        return new Result("400","查询失败！",null);
    }
    //根据一级权限查询所有项目
    @RequestMapping("/selectProductByOne")
    public Object selectProductByOne(int pageNum,int pageSize ,String onename){

        PageInfo<Productdetail> pro = service.selectProductByOne(pageNum, pageSize, onename);
        if (pro.getList().size()!=0){
            return new Result("200","查询成功！",pro);
        }
        return new Result("400","查询失败！",null);
    }
    //根据二级权限查询所有项目
    @RequestMapping("/selectProductByTwo")
    public Object selectProductByTwo(int pageNum,int pageSize ,String twoname){
        PageInfo<Productdetail> pro = service.selectProductByTwo(pageNum, pageSize,twoname);
        if (pro.getList().size()!=0){
            return new Result("200","查询成功！",pro);
        }
        return new Result("400","查询失败！",null);
    }

    @RequestMapping("/selectProductLevelAll")
    public Object selectProductLevel(int pageNum,int pageSize){
        PageInfo<ProductLevel> pageInfo = service.selectProductLevelAll(pageNum, pageSize);
        if (pageInfo.getList().size()!=0){
            return new Result("200","查询成功！",pageInfo);
        }
        return new Result("400","查询失败！",null);
    }

}
